package com.knowledge.plus.多线程.锁.内置锁;

/**
 * 任意实例对象Object
 * 被锁的对象：实例对象Object
 *
 * @author TPF
 * @since 2025/6/9
 */
public class BlockAnyObjectSync {

    private int count = 0;
    private final String lock = "";

    public void increment() {
        // 同步代码块，锁住的是配置的实例对象
        // String对象作为锁
        synchronized (lock) {
            count++;
        }
    }

}